﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;

namespace PortalCurriculo.Util.CustomControls
{
    public static class ValidateHelper
    {
        public static bool ValidateBirthday(string date, CultureInfo culture)
        {
            if (!ValidateDate(date, culture)) return false;

            DateTime convertedDate; 
            DateTime.TryParse(date, culture, DateTimeStyles.None, out convertedDate);

            if (convertedDate >= DateTime.Today)
                return false;
            if (convertedDate.AddYears(100) < DateTime.Today)
                return false;

            return true;
        }

        public static bool ValidateDate(string date, CultureInfo culture)
        {
            DateTime convertedDate;

            bool isValid = DateTime.TryParse(date, culture, DateTimeStyles.None, out convertedDate);

            return isValid;
        }


    }
}
